package com.luomu.base.api.bo;

import java.util.List;
import java.util.Objects;

public class RspPage<T> extends RspBaseBO {
    private static final long serialVersionUID = -6183978037199049936L;
    private List<T> rows;
    private long recordsTotal;
    private long total;
    private long pageNo;

    public RspPage() {
    }

    public List<T> getRows() {
        return this.rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    public long getRecordsTotal() {
        if(Objects.nonNull(rows.size()) && Objects.nonNull(this.total) && rows.size() > 0 && this.total > 0){
            return (int) Math.ceil((double) this.total / rows.size());
        }else {
            return 1L;
        }
    }

    public void setRecordsTotal(long recordsTotal) {
        this.recordsTotal = recordsTotal;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public long getPageNo() {
        return pageNo;
    }

    public void setPageNo(long pageNo) {
        this.pageNo = pageNo;
    }

    public String toString() {
        return "RspPageBO [rows=" + this.rows + ", recordsTotal=" + this.recordsTotal + ", total=" + this.total + ", toString()=" + super.toString() + "]";
    }
}
